<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>获取时间</title>
</head>

<body>
    <div class="date" id="date"></div>
    <script>
        const getColonTimeFromDate = date => date.toTimeString().slice(0, 8);
        const date = document.querySelector("#date");
        const run = () => {
            const currentTime = getColonTimeFromDate(new Date());
            date.innerHTML = currentTime;
            setTimeout(run, 1000)
        }
        run()
    </script>
</body>

</html>